package com.example.a12769.myapplication.utils.http_utils;

import com.trello.rxlifecycle2.LifecycleTransformer;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class ApiMethods {
    //辅助线程管理和订阅过程
    public static void ApiSubscribe(Observable observable, Observer observer, LifecycleTransformer<Object> lifecycle) {
        //不需要缓存
        observable.subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(lifecycle)
                .subscribe(observer);
    }

    //首页获取轮播图
    public static void getBannerBean(Observer<BannerBean> observer, int adtType, LifecycleTransformer<Object> lifecycle) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getBannerBean(adtType), observer,lifecycle);
    }

   /* //获取用户需要信息从后台服务器
    public static void getNeedMessage(Observer<Movie> observer, int start, int count, final ActivityLifeCycleEvent event, final PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getTopMovie(start, count), observer, event, lifecycleSubject);
    }
*/
   /* //获取用户登录个人信息
    public static void getLoginUserMessage(Observer<UserInformation> observer, String userTelNo, String password) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getUserInformation(userTelNo, password), observer);
    }

    //首页获取轮播图
    public static void getBannerBean(Observer<BannerBean> observer, int adtType) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getBannerBean(adtType), observer);
    }

    //首页阅读任务
    public static void getReaderTaskBean(Observer<ReadTaskBean> observer, HashMap<String ,String > hashMap) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getReadTaskBean(hashMap), observer);
    }

    //首页弹窗的网络请求
    public static void getCustomImageBean(Observer<CustomImageBean> observer, int adtType) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getLoadImageView(adtType), observer);
    }

    //欢迎页面广告的网络请求
    public static void getWellcomImageBean(Observer<WellcomImageBean> observer, int adtType) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getWellcomImageView(adtType), observer);
    }

    //修改个人信息
    public static void sendUserInforMToServer(Observer<MessageResultBean> observer, HashMap<String, String> sendToServehashMap) {
        ApiSubscribe(ApiStrategy.getApiStrategy().sendMessageToServer(sendToServehashMap), observer);
    }

    //获取个人信息
    public static void getUserInforM(Observer<UserInformation> observer, String userId) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getUseMessageBean(userId), observer);
    }

    //用户注册
    public static void registUserInforToServer(Observer<RegistBean> observer, HashMap<String, String> hashMap) {
        ApiSubscribe(ApiStrategy.getApiStrategy().registUserInforToServer(hashMap), observer);
    }

    //获取今日收入
    public static void getTodayIncomeMoney(Observer<TodayInMoney> observer, String userId) {
        ApiSubscribe(ApiStrategy.getApiStrategy().comAndBalance(userId), observer);
    }

    //上传头像
    public static void sendPictorToServer(Observer<RegistBean> observer, MultipartBody.Part file, String userId) {
        ApiSubscribe(ApiStrategy.getApiStrategy().SendPctureToServer(file, userId), observer);
    }

    //修改个人密码
    public static void changedPassword(Observer<ChangePwdBean> observer, HashMap<String, String> hashMap) {
        ApiSubscribe(ApiStrategy.getApiStrategy().changedPassword(hashMap), observer);

    }

    //这里用来获取收入信息
    public static void getComeInMoney(Observer<PaymentDetailBean> observer, HashMap<String, String> hashMap) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getIncomeMessage(hashMap), observer);

    }

    //这里获取收支明细
    public static void getIncomeMessage(Observer<GitMoneyInforBean> observer, HashMap<String, String> hashMap) {
        ApiSubscribe(ApiStrategy.getApiStrategy().getMoneyInfor(hashMap), observer);
    }
    //这里获取累计收入
    public static void getIncomeTayDay(Observer<InComeBean> observer, String userId){
        ApiSubscribe(ApiStrategy.getApiStrategy().getMessageIncome(userId),observer);
    }*/
}
